package com.EpidemicPrevention.service;

import com.EpidemicPrevention.mapper.Item_infoMapper;
import com.EpidemicPrevention.pojo.Item_info;
import com.EpidemicPrevention.pojo.Volunteerinfo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Item_infoServiceImpl implements Item_infoService {
    @Autowired
    private Item_infoMapper item_infoMapper;


    @Override
    public JSON addItem_info(Item_info item_info) {
        JSONObject json = new JSONObject();

        int code =0;
        code = item_infoMapper.addItem_info(item_info);
        if (code ==1){
            json.put("msg","添加成功");
            json.put("code",1);
        }else {
            json.put("msg","添加失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON deleteItem_info(int id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = item_infoMapper.deleteItem_info(id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON updateItem_info(Item_info item_info) {
        JSONObject json = new JSONObject();

        int code=0;
        code=item_infoMapper.updateItem_info(item_info);
        if (code==1){
            json.put("msg","修改项目信息成功");
            json.put("code",1);
        }else{
            json.put("msg","修改项目信息失败");
            json.put("code",0);
        }

        return json;
    }

    @Override
    public List<Item_info> queryItem_info (int page, int limit,String Keyword) {
        return item_infoMapper.queryItem_info(page, limit,null);
    }




    @Override
    public List<Item_info> selectWhereItem_info() {
        return item_infoMapper.selectWhereItem_info();
    }

}
